package roboticsfmw.sample.processor;

import roboticsfmw.annotation.HardwareRef;
import roboticsfmw.annotation.OnEvent;
import roboticsfmw.common.ShutdownEvent;
import roboticsfmw.core.Processor;
import roboticsfmw.sample.event.SleepEvent;
import roboticsfmw.sample.event.WakeEvent;
import roboticsfmw.sample.hardware.EyesHardwareProxy;


public class EyesProcessor extends Processor {

	@HardwareRef(name = "/hw/eyes")
	private EyesHardwareProxy eyesHardware;

	
	public EyesProcessor(String name, long pollInterval, boolean loop) throws IllegalArgumentException {
		super(name, pollInterval, loop);
	}

	public EyesHardwareProxy getEyesHardware() {
		return eyesHardware;
	}

	public void setEyesHardware(EyesHardwareProxy eyesHardware) {
		this.eyesHardware = eyesHardware;
	}

	@Override
	public void init() {
	}

	@OnEvent(ShutdownEvent.class)
	public void onShutdownEvent(ShutdownEvent event) {
		eyesHardware.closeEyes();
	}
	
	@OnEvent(SleepEvent.class)
	public void onSleepEvent(SleepEvent event) {
		eyesHardware.closeEyes();
	}

	@OnEvent(WakeEvent.class)
	public void onWakeEvent(WakeEvent event) {
		eyesHardware.openEyes();
	}

	@Override
	public void loop(long i) {
	}

	@Override
	public void shutdown() {
	}

}
